home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / knewstuff / provider.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.9 KB  |  215 lines

  1. /*
  2.     This file is part of KOrganizer.
  3.     Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef KNEWSTUFF_PROVIDER_H
  21. #define KNEWSTUFF_PROVIDER_H
  22.  
  23. #include <qcstring.h>
  24. #include <qdom.h>
  25. #include <qobject.h>
  26. #include <qptrlist.h>
  27. #include <qstring.h>
  28.  
  29. #include <kurl.h>
  30.  
  31. namespace KIO { class Job; }
  32.  
  33. namespace KNS {
  34.  
  35. /**
  36.  * @short KNewStuff provider container.
  37.  *
  38.  * This class provides accessors for the provider object.
  39.  * as used by KNewStuff.
  40.  * It should probably not be used directly by the application.
  41.  *
  42.  * @author Cornelius Schumacher (schumacher@kde.org)
  43.  * \par Maintainer:
  44.  * Josef Spillner (spillner@kde.org)
  45.  */
  46. class KDE_EXPORT Provider
  47. {
  48.   public:
  49.     typedef QPtrList<Provider> List;
  50.  
  51.     /**
  52.      * Constructor.
  53.      */
  54.     Provider();
  55.  
  56.     /**
  57.      * Constructor with XML feed.
  58.      */
  59.     Provider( const QDomElement & );
  60.  
  61.     /**
  62.      * Destructor.
  63.      */
  64.     ~Provider();
  65.  
  66.     /**
  67.      * Sets the common name of the provider.
  68.      */
  69.     void setName( const QString & );
  70.  
  71.     /**
  72.      * Retrieves the common name of the provider.
  73.      *
  74.      * @return provider name
  75.      */
  76.     QString name() const;
  77.  
  78.     /**
  79.      * Sets the download URL.
  80.      */
  81.     void setDownloadUrl( const KURL & );
  82.  
  83.     /**
  84.      * Retrieves the download URL.
  85.      *
  86.      * @return download URL
  87.      */
  88.     KURL downloadUrl() const;
  89.  
  90.     /**
  91.      * Variant to retrieve 'tagged' download URLs.
  92.      * Variant can be one of 'score', 'downloads', 'latest'.
  93.      *
  94.      * @return download specific URL
  95.      */
  96.     KURL downloadUrlVariant( QString variant ) const;
  97.  
  98.     /**
  99.      * Sets the upload URL.
  100.      */
  101.     void setUploadUrl( const KURL & );
  102.  
  103.     /**
  104.      * Retrieves the upload URL.
  105.      *
  106.      * @return upload URL
  107.      */
  108.     KURL uploadUrl() const;
  109.  
  110.     /**
  111.      * Sets the URL where a user is led if the provider does not support
  112.      * uploads.
  113.      *
  114.      * @see setNoUpload
  115.      */
  116.     void setNoUploadUrl( const KURL & );
  117.  
  118.     /**
  119.      * Retrieves the URL where a user is led if the provider does not
  120.      * support uploads.
  121.      *
  122.      * @return website URL
  123.      */
  124.     KURL noUploadUrl() const;
  125.  
  126.     /**
  127.      * Indicate whether provider supports uploads.
  128.      */
  129.     void setNoUpload( bool );
  130.  
  131.     /**
  132.      * Query whether provider supports uploads.
  133.      *
  134.      * @return upload support status
  135.      */
  136.     bool noUpload() const;
  137.  
  138.     /**
  139.      * Sets the URL for an icon for this provider.
  140.      * The icon should be in 32x32 format. If not set, the default icon
  141.      * of KDialogBase is used.
  142.      */
  143.     void setIcon( const KURL & );
  144.  
  145.     /**
  146.      * Retrieves the icon URL for this provider.
  147.      *
  148.      * @return icon URL
  149.      */
  150.     KURL icon() const;
  151.  
  152.   protected:
  153.     void parseDomElement( const QDomElement & );
  154.  
  155.     QDomElement createDomElement( QDomDocument &, QDomElement &parent );
  156.  
  157.   private:
  158.     QString mName;
  159.     KURL mDownloadUrl;
  160.     KURL mUploadUrl;
  161.     KURL mNoUploadUrl;
  162.     KURL mIcon;
  163.     bool mNoUpload;
  164. };
  165.  
  166. /**
  167.  * KNewStuff provider loader.
  168.  * This class sets up a list of all possible providers by querying
  169.  * the main provider database for this specific application.
  170.  * It should probably not be used directly by the application.
  171.  */
  172. class KDE_EXPORT ProviderLoader : public QObject
  173. {
  174.     Q_OBJECT
  175.   public:
  176.     /**
  177.      * Constructor.
  178.      *
  179.      * @param parentWidget the parent widget
  180.      */
  181.     ProviderLoader( QWidget *parentWidget );
  182.  
  183.     /**
  184.      * Starts asynchronously loading the list of providers of the
  185.      * specified type.
  186.      *
  187.      * @param type data type such as 'kdesktop/wallpaper'.
  188.      * @param providerList the URl to the list of providers; if empty
  189.      *    we first try the ProvidersUrl from KGlobal::config, then we
  190.      *    fall back to a hardcoded value.
  191.      */
  192.     void load( const QString &type, const QString &providerList = QString::null );
  193.  
  194.   signals:
  195.     /**
  196.      * Indicates that the list of providers has been successfully loaded.
  197.      */
  198.     void providersLoaded( Provider::List * );
  199.  
  200.   protected slots:
  201.     void slotJobData( KIO::Job *, const QByteArray & );
  202.     void slotJobResult( KIO::Job * );
  203.  
  204.   private:
  205.     QWidget *mParentWidget;
  206.  
  207.     QString mJobData;
  208.  
  209.     Provider::List mProviders;
  210. };
  211.  
  212. }
  213.  
  214. #endif
  215.